package com.main.crossdomaineventmanagement.event.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;

import java.time.Instant;
import java.util.UUID;

@Data
public class EventMessage {
    private String eventId;
    private String eventType;
    private String source;
    private String payload;  // payload 是嵌套的 JSON 字符串
    @JsonFormat(shape = JsonFormat.Shape.NUMBER)
    private Instant timestamp;

    public EventMessage() {}

    public EventMessage(String eventType, String source, String payload) {
        this.eventId = UUID.randomUUID().toString();
        this.eventType = eventType;
        this.source = source;
        this.payload = payload;
        this.timestamp = Instant.now();
    }
}